import React, {Component} from 'react'
import {connect} from 'react-redux'
import { Link } from "react-router-dom"

import Header from "../components/header"
import {loadPlayList} from "../redux/actions/findAction"

class playitemContainer extends Component {
  constructor (props){
   super(props)
   this.state= {}
}

componentDidMount(){
  const {dispatch,match,find} = this.props
  let gameCode = match.params.key
  find.get("play")[gameCode] || dispatch(loadPlayList(gameCode))
}

  render() {
    const {find} = this.props
    let gameCode = this.props.match.params.key
    const play = find.get("play")[gameCode] || {ruleName:""}
    // console.log(play,"play");
    
  return  <div className="allaward">
            <Header title={play.ruleName+"玩法介绍"} {...this.props}></Header>
            <div className="play">
            <div className="rule-page">
              <div dangerouslySetInnerHTML={{__html: play.ruleContent}}></div>
            </div>
            </div>
   </div> 
      
    }
  }

function mapStateToProps(state) {
  return {
    find: state.find
  }
}

export default connect(mapStateToProps)(playitemContainer)